package org.sandbox2.web;

import org.sandbox2.domain.loan.LoanBalanceForm;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.web.mvc.controller.RooWebScaffold;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;

@RooWebScaffold(path = "loanbalanceforms", formBackingObject = LoanBalanceForm.class)
@RequestMapping("/loanbalanceforms")
@Controller
public class LoanBalanceFormController {
	@RequestMapping(params = "find=ByBorrowerIdAndPaymentDate", method = RequestMethod.GET)
    public String findLoanBalanceFormsByBorrowerIdAndPaymentDate(@RequestParam("borrowerId") Long borrowerId, @RequestParam("paymentDate") @DateTimeFormat(style = "S-") Date paymentDate, Model uiModel) {
        uiModel.addAttribute("loanbalanceforms", LoanBalanceForm.findLoanBalanceFormsByBorrowerIdAndPaymentDate(borrowerId, paymentDate));
        addDateTimeFormatPatterns(uiModel);
        return "loanbalanceforms/list";
    }
}
